package com.jchz.net;

import android.app.Application;
import android.content.Context;
import android.text.TextUtils;

import com.jchz.net.comhttp.AppNetConfig;
import com.jchz.net.comhttp.DcodeService;
import com.jchz.net.util.SpUtils;
import com.utils.gyymz.BaseApplicationCompat;


public class APP extends Application {
    private static Context m_objContext = null;

    public void onCreate() {
        super.onCreate();
        BaseApplicationCompat.instance().initialize(this);
        SpUtils.getInstance().init(this);
        initNetWork();
    }

    public static Context getAppContext() {
        return APP.m_objContext;
    }

    public void initNetWork() {
        DcodeService.initialize(this);
        String baseUrl;
        if (!TextUtils.isEmpty(SpUtils.getInstance().getString(AppConfig.KEY_BASEURL))) {
            baseUrl = SpUtils.getInstance().getString(AppConfig.KEY_BASEURL);
        } else {
            baseUrl = AppConfig.HTTP_ENCRYPT_BASE;
            SpUtils.getInstance().saveString(AppConfig.KEY_IP, AppConfig.SERVICE_IP);
        }
        AppNetConfig.getInstance().setBuider(new AppNetConfig.Builder()
                .setBaseUrl(baseUrl));

    }

}
